home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / hplip / base / wifi.pyc (.txt) < prev   
Python Compiled Bytecode  |  2009-10-28  |  19KB  |  564 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import time
  5. import cStringIO
  6. import xml.parsers.expat as xml
  7. from base.g import *
  8. from base import device, utils
  9. MAX_NETWORKS = 100
  10. MAX_RETRIES = 20
  11. NS = 'http://www.hp.com/schemas/imaging/cnc/dcsl/2006/05/WifiConfig'
  12. PREAMBLE = '<?xml version="1.0" encoding="utf-8"?>\n<WiFiConfig xmlns="%s">\n' % NS
  13.  
  14. def _readWriteWifiConfig(dev, request):
  15.     if not request:
  16.         log.error('Invalid request')
  17.         return ('executionfailed', { })
  18.     log.debug('Sending request on wifi config channel...')
  19.     log.log_data(request)
  20.     bytes_written = dev.writeWifiConfig(request)
  21.     log.debug('Wrote %d bytes.' % bytes_written)
  22.     data = cStringIO.StringIO()
  23.     log.debug('Reading response on wifi config channel...')
  24.     bytesread = dev.readWifiConfig(device.MAX_BUFFER, stream = data, timeout = 30)
  25.     i = 0
  26.     while True:
  27.         i += 1
  28.         bytesread = dev.readWifiConfig(device.MAX_BUFFER, stream = data, timeout = 1)
  29.         if not bytesread or i > MAX_RETRIES:
  30.             break
  31.             continue
  32.         request
  33.     data = data.getvalue()
  34.     data = utils.unescape(data)
  35.     data = unicode(data, 'utf-8')
  36.     data = data.replace(u'Devicecapabilities', u'DeviceCapabilities').replace('\x00', '')
  37.     log.log_data(data)
  38.     log.debug('Read %d bytes.' % len(data))
  39.     if not data:
  40.         log.error('No data')
  41.         return ('executionfailed', { })
  42.     
  43.     try:
  44.         params = utils.XMLToDictParser().parseXML(data)
  45.     except xml.parsers.expat.ExpatError:
  46.         data
  47.         e = data
  48.         log.error('XML parser failed: %s' % e)
  49.         match = re.search('line\\s*(\\d+).*?column\\s*(\\d+)', str(e), re.I)
  50.         if match is not None:
  51.             log.error(data[int(match.group(2)):])
  52.         
  53.         return ('executionfailed', { })
  54.  
  55.     errorreturn = 'executionfailed'
  56.     for p in params:
  57.         if p.lower().endswith('errorreturn'):
  58.             errorreturn = params[p].lower()
  59.             break
  60.             continue
  61.         data
  62.     
  63.     params['errorreturn'] = errorreturn
  64.     return (errorreturn, params)
  65.  
  66.  
  67. def getDeviceCapabilities(dev):
  68.     ret = { }
  69.     request = PREAMBLE + '<GetDeviceCapabilitiesRequest>\n</GetDeviceCapabilitiesRequest>\n</WiFiConfig>'
  70.     (errorreturn, params) = _readWriteWifiConfig(dev, request)
  71.     if not params:
  72.         return { }
  73.     ret['errorreturn'] = errorreturn
  74.     if errorreturn != 'ok':
  75.         log.error('GetDeviceCapabilities returned an error: %s' % errorreturn)
  76.         return ret
  77.     param_keys = [
  78.         'wificonfig-getdevicecapabilitiesresponse-devicecapabilities-numberofsupportedwifiaccessories',
  79.         'wificonfig-getdevicecapabilitiesresponse-interfaceversion-minorreleasenumber',
  80.         'wificonfig-getdevicecapabilitiesresponse-interfaceversion-majorreleasenumber']
  81.     for p in param_keys:
  82.         
  83.         try:
  84.             ret[p.split('-')[-1]] = params[p]
  85.         continue
  86.         except KeyError:
  87.             errorreturn != 'ok'
  88.             errorreturn != 'ok'
  89.             params
  90.             log.debug('Missing response key: %s' % p)
  91.             continue
  92.             continue
  93.         
  94.  
  95.     
  96.     return ret
  97.  
  98.  
  99. def getAdaptorList(dev):
  100.     ret = { }
  101.     request = PREAMBLE + '<GetAdaptorListRequest>\n</GetAdaptorListRequest>\n</WiFiConfig>'
  102.     (errorreturn, params) = _readWriteWifiConfig(dev, request)
  103.     if not params:
  104.         return {
  105.             'adaptorlistlength': 0 }
  106.     ret['errorreturn'] = errorreturn
  107.     if errorreturn != 'ok':
  108.         log.error('GetAdaptorList returned an error: %s' % errorreturn)
  109.         return ret
  110.     
  111.     try:
  112.         adaptor_list_length = int(params['wificonfig-getadaptorlistresponse-adaptorlistlength'])
  113.     except (ValueError, KeyError):
  114.         errorreturn != 'ok'
  115.         errorreturn != 'ok'
  116.         params
  117.         adaptor_list_length = 0
  118.     except:
  119.         errorreturn != 'ok'
  120.  
  121.     ret['adaptorlistlength'] = adaptor_list_length
  122.     params if adaptor_list_length == 0 else params
  123.     for a in xrange(adaptor_list_length):
  124.         
  125.         try:
  126.             ret['adaptorid-%d' % a] = params['wificonfig-getadaptorlistresponse-adaptorlist-adaptorinfo-adaptorid-%d' % a]
  127.             ret['adaptorname-%d' % a] = params['wificonfig-getadaptorlistresponse-adaptorlist-adaptorinfo-adaptorname-%d' % a]
  128.             ret['adaptorpresence-%d' % a] = params['wificonfig-getadaptorlistresponse-adaptorlist-adaptorinfo-adaptorpresence-%d' % a]
  129.             ret['adaptorstate-%d' % a] = params['wificonfig-getadaptorlistresponse-adaptorlist-adaptorinfo-adaptorstate-%d' % a]
  130.             ret['adaptortype-%d' % a] = params['wificonfig-getadaptorlistresponse-adaptorlist-adaptorinfo-adaptortype-%d' % a]
  131.         continue
  132.         except KeyError:
  133.             e = None
  134.             log.debug('Missing response key: %s' % e)
  135.             continue
  136.         
  137.  
  138.     
  139.     return ret
  140.  
  141.  
  142. def getWifiAdaptorID(dev):
  143.     ret = getAdaptorList(dev)
  144.     
  145.     try:
  146.         num_adaptors = ret['adaptorlistlength']
  147.     except KeyError:
  148.         num_adaptors = 0
  149.  
  150.     for n in xrange(num_adaptors):
  151.         
  152.         try:
  153.             name = ret['adaptortype-%d' % n]
  154.         except KeyError:
  155.             name = ''
  156.  
  157.         if name.lower() in ('wifiembedded', 'wifiaccessory'):
  158.             params = [
  159.                 'adaptorid',
  160.                 'adaptorname',
  161.                 'adaptorstate',
  162.                 'adaptorpresence']
  163.             r = []
  164.             for p in params:
  165.                 
  166.                 try:
  167.                     x = ret[''.join([
  168.                         p,
  169.                         '-',
  170.                         str(n)])]
  171.                 except KeyError:
  172.                     if p == 'adaptorid':
  173.                         x = -1
  174.                     else:
  175.                         x = 'Unknown'
  176.                 except:
  177.                     p == 'adaptorid'
  178.  
  179.                 r.append(x)
  180.             
  181.             return r
  182.     
  183.     return (-1, 'Unknown', 'Unknown', 'Unknown')
  184.  
  185.  
  186. def setAdaptorPower(dev, adaptor_id = 0, power_state = 'PowerOn'):
  187.     ret = { }
  188.     request = PREAMBLE + '<SetAdaptorPowerRequest>\n<AdaptorID>%s</AdaptorID>\n<PowerState>%s</PowerState>\n</SetAdaptorPowerRequest>\n</WiFiConfig>' % (adaptor_id, power_state.encode('utf-8'))
  189.     (errorreturn, params) = _readWriteWifiConfig(dev, request)
  190.     if not params:
  191.         return { }
  192.     ret['errorreturn'] = errorreturn
  193.     if errorreturn != 'ok':
  194.         log.error('SetAdaptorPower returned an error: %s' % errorreturn)
  195.         return ret
  196.     return ret
  197.  
  198.  
  199. def performScan(dev, ssid = None):
  200.     ret = { }
  201.     i = 0
  202.     scan_state = 'NewScan'
  203.     while True:
  204.         if ssid is None:
  205.             request = PREAMBLE + '<UndirectedScanRequest>\n<ScanState>%s</ScanState>\n</UndirectedScanRequest>\n</WiFiConfig>' % scan_state
  206.             typ = 'UndirectedScan'
  207.             rsp = 'undirectedscanresponse'
  208.         else:
  209.             request = PREAMBLE + '<DirectedScanRequest>\n<SSID>%s</SSID>\n<ScanState>%s</ScanState>\n</DirectedScanRequest>\n</WiFiConfig>' % (ssid.encode('utf-8'), scan_state)
  210.             typ = 'Directed'
  211.             rsp = 'directedscanresponse'
  212.         (errorreturn, params) = _readWriteWifiConfig(dev, request)
  213.         if not params:
  214.             return {
  215.                 'numberofscanentries': 0 }
  216.         ret['errorreturn'] = errorreturn
  217.         if errorreturn != 'ok':
  218.             log.error('%s returned an error: %s' % (typ, errorreturn))
  219.             return ret
  220.         
  221.         try:
  222.             number_of_scan_entries = int(params['wificonfig-%s-numberofscanentries' % rsp])
  223.         except (ValueError, KeyError):
  224.             errorreturn != 'ok'
  225.             errorreturn != 'ok'
  226.             params
  227.             number_of_scan_entries = 0
  228.         except:
  229.             errorreturn != 'ok'
  230.  
  231.         ret['numberofscanentries'] = number_of_scan_entries
  232.         params if number_of_scan_entries == 0 else params
  233.         for a in xrange(number_of_scan_entries):
  234.             j = a + i
  235.             
  236.             try:
  237.                 ssid = params['wificonfig-%s-scanlist-scanentry-ssid-%d' % (rsp, j)]
  238.                 if not ssid:
  239.                     ret['ssid-%d' % j] = u'(unknown)'
  240.                 else:
  241.                     ret['ssid-%d' % j] = ssid
  242.                 ret['bssid-%d' % j] = params['wificonfig-%s-scanlist-scanentry-bssid-%d' % (rsp, j)]
  243.                 ret['channel-%d' % j] = params['wificonfig-%s-scanlist-scanentry-channel-%d' % (rsp, j)]
  244.                 ret['communicationmode-%d' % j] = params['wificonfig-%s-scanlist-scanentry-communicationmode-%d' % (rsp, j)]
  245.                 ret['dbm-%d' % j] = params['wificonfig-%s-scanlist-scanentry-dbm-%d' % (rsp, j)]
  246.                 ret['encryptiontype-%d' % j] = params['wificonfig-%s-scanlist-scanentry-encryptiontype-%d' % (rsp, j)]
  247.                 ret['rank-%d' % j] = params['wificonfig-%s-scanlist-scanentry-rank-%d' % (rsp, j)]
  248.                 ret['signalstrength-%d' % j] = params['wificonfig-%s-scanlist-scanentry-signalstrength-%d' % (rsp, j)]
  249.             continue
  250.             except KeyError:
  251.                 e = None
  252.                 log.debug('Missing response key: %s' % e)
  253.                 continue
  254.             
  255.  
  256.         
  257.         
  258.         try:
  259.             ret['signalstrengthmax'] = params['wificonfig-%s-scansettings-signalstrengthmax' % rsp]
  260.             ret['signalstrengthmin'] = params['wificonfig-%s-scansettings-signalstrengthmin' % rsp]
  261.         except KeyError:
  262.             None<EXCEPTION MATCH>KeyError
  263.             e = None<EXCEPTION MATCH>KeyError
  264.             log.debug('Missing response key: %s' % e)
  265.         except:
  266.             None<EXCEPTION MATCH>KeyError
  267.  
  268.         if scan_state.lower() == 'scancomplete':
  269.             break
  270.         
  271.         scan_state = 'ResumeScan'
  272.         i += number_of_scan_entries
  273.         if i > MAX_NETWORKS:
  274.             break
  275.         
  276.         time.sleep(2)
  277.     return ret
  278.  
  279.  
  280. def associate(dev, ssid, communication_mode, encryption_type, key):
  281.     ret = { }
  282.     request = PREAMBLE + '<AssociateRequest>\n<SSID>%s</SSID>\n<CommunicationMode>%s</CommunicationMode>\n<EncryptionType>%s</EncryptionType>\n<EncryptedParameters>%s</EncryptedParameters>\n<Key>%s</Key>\n</AssociateRequest>\n</WiFiConfig>' % (ssid.encode('utf-8'), communication_mode.encode('utf-8'), encryption_type.encode('utf-8'), u'False'.encode('utf-8'), key.encode('utf-8'))
  283.     (errorreturn, params) = _readWriteWifiConfig(dev, request)
  284.     if not params:
  285.         return { }
  286.     ret['errorreturn'] = errorreturn
  287.     if errorreturn != 'ok':
  288.         log.error('Associate returned an error: %s' % errorreturn)
  289.         return ret
  290.     return ret
  291.  
  292.  
  293. def getVSACodes(dev):
  294.     ret = []
  295.     request = PREAMBLE + '<GetVSACodesRequest>\n</GetVSACodesRequest>\n</WiFiConfig>'
  296.     (errorreturn, params) = _readWriteWifiConfig(dev, request)
  297.     if not params:
  298.         return []
  299.     if errorreturn != 'ok':
  300.         log.error('GetVSACodes returned an error: %s' % errorreturn)
  301.         return ret
  302.     
  303.     try:
  304.         rule = params['wificonfig-getvsacodesresponse-vsacodelist-vsacode-rulenumber']
  305.         severity = params['wificonfig-getvsacodesresponse-vsacodelist-vsacode-severity']
  306.     except KeyError:
  307.         errorreturn != 'ok'
  308.         errorreturn != 'ok'
  309.         params
  310.         n = 0
  311.         while True:
  312.             
  313.             try:
  314.                 rule = params['wificonfig-getvsacodesresponse-vsacodelist-vsacode-rulenumber-%d' % n]
  315.             except KeyError:
  316.                 break
  317.  
  318.             severity = params['wificonfig-getvsacodesresponse-vsacodelist-vsacode-severity-%d' % n]
  319.             ret.append((rule, severity))
  320.             n += 1
  321.     except:
  322.         errorreturn != 'ok'
  323.  
  324.     ret.append((rule, severity))
  325.     return ret
  326.  
  327.  
  328. def __getIPConfiguration(dev, adaptor_id = 0):
  329.     ret = { }
  330.     request = PREAMBLE + '<GetIPConfigurationRequest>\n<AdaptorID>%d</AdaptorID>\n</GetIPConfigurationRequest>\n</WiFiConfig>' % adaptor_id
  331.     (errorreturn, params) = _readWriteWifiConfig(dev, request)
  332.     if not params:
  333.         return { }
  334.     ret['errorreturn'] = errorreturn
  335.     if errorreturn != 'ok':
  336.         log.error('GetIPConfiguration returned an error: %s' % errorreturn)
  337.         return ret
  338.     param_keys = [
  339.         'wificonfig-getipconfigurationresponse-ipconfiguration-addressmode',
  340.         'wificonfig-getipconfigurationresponse-ipconfiguration-alternatednsaddress',
  341.         'wificonfig-getipconfigurationresponse-ipconfiguration-gatewayaddress',
  342.         'wificonfig-getipconfigurationresponse-ipconfiguration-ipaddress',
  343.         'wificonfig-getipconfigurationresponse-ipconfiguration-primarydnsaddress',
  344.         'wificonfig-getipconfigurationresponse-ipconfiguration-subnetmask',
  345.         'wificonfig-getipconfigurationresponse-networkconfiguration-hostname']
  346.     for p in param_keys:
  347.         
  348.         try:
  349.             ret[p.split('-')[-1]] = params[p]
  350.         continue
  351.         except KeyError:
  352.             errorreturn != 'ok'
  353.             errorreturn != 'ok'
  354.             params
  355.             log.debug('Missing response key: %s' % p)
  356.             continue
  357.             continue
  358.         
  359.  
  360.     
  361.     return ret
  362.  
  363.  
  364. def getIPConfiguration(dev, adaptor_id = 0):
  365.     (ip, hostname, addressmode, subnetmask, gateway, pridns, sec_dns) = ('0.0.0.0', 'Unknown', 'Unknown', '0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0')
  366.     ret = __getIPConfiguration(dev, adaptor_id)
  367.     if ret and ret['errorreturn'].lower() == 'ok':
  368.         
  369.         try:
  370.             ip = ret['ipaddress']
  371.             hostname = ret['hostname']
  372.             addressmode = ret['addressmode']
  373.             subnetmask = ret['subnetmask']
  374.             gateway = ret['gatewayaddress']
  375.             pridns = ret['primarydnsaddress']
  376.             sec_dns = ret['alternatednsaddress']
  377.         except KeyError:
  378.             e = None
  379.             log.debug('Missing response key: %s' % str(e))
  380.         except:
  381.             None<EXCEPTION MATCH>KeyError
  382.         
  383.  
  384.     None<EXCEPTION MATCH>KeyError
  385.     return (ip, hostname, addressmode, subnetmask, gateway, pridns, sec_dns)
  386.  
  387.  
  388. def __getSignalStrength(dev, adaptor_id = 0):
  389.     ret = { }
  390.     request = PREAMBLE + '<GetSignalStrengthRequest>\n<AdaptorID>%d</AdaptorID>\n</GetSignalStrengthRequest>\n</WiFiConfig>' % adaptor_id
  391.     (errorreturn, params) = _readWriteWifiConfig(dev, request)
  392.     if not params:
  393.         return { }
  394.     ret['errorreturn'] = errorreturn
  395.     if errorreturn != 'ok':
  396.         log.error('GetSignalStrength returned an error: %s' % errorreturn)
  397.         return ret
  398.     param_keys = [
  399.         'wificonfig-getsignalstrengthresponse-signalstrength-dbm',
  400.         'wificonfig-getsignalstrengthresponse-signalstrength-signalstrengthmax',
  401.         'wificonfig-getsignalstrengthresponse-signalstrength-signalstrengthmin',
  402.         'wificonfig-getsignalstrengthresponse-signalstrength-signalstrengthvalue']
  403.     for p in param_keys:
  404.         
  405.         try:
  406.             ret[p.split('-')[-1]] = params[p]
  407.         continue
  408.         except KeyError:
  409.             errorreturn != 'ok'
  410.             errorreturn != 'ok'
  411.             params
  412.             log.debug('Missing response key: %s' % p)
  413.             continue
  414.             continue
  415.         
  416.  
  417.     
  418.     return ret
  419.  
  420.  
  421. def getSignalStrength(dev, adaptor_id = 0):
  422.     (ss_max, ss_min, ss_val, ss_dbm) = (5, 0, 0, -200)
  423.     ret = __getSignalStrength(dev, adaptor_id)
  424.     if ret and ret['errorreturn'].lower() == 'ok':
  425.         
  426.         try:
  427.             ss_max = ret['signalstrengthmax']
  428.             ss_min = ret['signalstrengthmin']
  429.             ss_val = ret['signalstrengthvalue']
  430.             ss_dbm = ret['dbm']
  431.         except KeyError:
  432.             e = None
  433.             log.debug('Missing response key: %s' % str(e))
  434.         except:
  435.             None<EXCEPTION MATCH>KeyError
  436.         
  437.  
  438.     None<EXCEPTION MATCH>KeyError
  439.     return (ss_max, ss_min, ss_val, ss_dbm)
  440.  
  441.  
  442. def __getCryptoSuite(dev):
  443.     ret = { }
  444.     request = PREAMBLE + '<GetCryptoSuiteRequest>\n</GetCryptoSuiteRequest>\n</WiFiConfig>'
  445.     (errorreturn, params) = _readWriteWifiConfig(dev, request)
  446.     if not params:
  447.         return { }
  448.     ret['errorreturn'] = errorreturn
  449.     if errorreturn != 'ok':
  450.         log.error('GetSignalStrength returned an error: %s' % errorreturn)
  451.         return ret
  452.     param_keys = [
  453.         'wificonfig-getcryptosuiteresponse-cryposuite-crypoalgorithm',
  454.         'wificonfig-getcryptosuiteresponse-cryposuite-crypomode',
  455.         'wificonfig-getcryptosuiteresponse-cryposuite-secretid']
  456.     for p in param_keys:
  457.         
  458.         try:
  459.             ret[p.split('-')[-1]] = params[p]
  460.         continue
  461.         except KeyError:
  462.             errorreturn != 'ok'
  463.             errorreturn != 'ok'
  464.             params
  465.             log.debug('Missing response key: %s' % p)
  466.             continue
  467.             continue
  468.         
  469.  
  470.     
  471.     return ret
  472.  
  473.  
  474. def getCryptoSuite(dev):
  475.     (alg, mode, secretid) = ('', '', '')
  476.     ret = __getCryptoSuite(dev)
  477.     if ret and ret['errorreturn'].lower() == 'ok':
  478.         
  479.         try:
  480.             alg = ret['crypoalgorithm']
  481.             mode = ret['crypomode']
  482.             secretid = ret['secretid']
  483.         except KeyError:
  484.             e = None
  485.             log.debug('Missing response key: %s' % str(e))
  486.         except:
  487.             None<EXCEPTION MATCH>KeyError
  488.         
  489.  
  490.     None<EXCEPTION MATCH>KeyError
  491.     return (alg, mode, secretid)
  492.  
  493.  
  494. def getHostname(dev):
  495.     ret = ''
  496.     request = PREAMBLE + '<GetHostnameRequest>\n</GetHostnameRequest>\n</WiFiConfig>'
  497.     (errorreturn, params) = _readWriteWifiConfig(dev, request)
  498.     if not params:
  499.         return ret
  500.     if errorreturn != 'ok':
  501.         log.error('GetHostname returned an error: %s' % errorreturn)
  502.         return ret
  503.     
  504.     try:
  505.         ret = params['wificonfig-gethostnameresponse-hostname']
  506.     except KeyError:
  507.         errorreturn != 'ok'
  508.         errorreturn != 'ok'
  509.         params
  510.         log.debug('Missing response key: hostname')
  511.     except:
  512.         errorreturn != 'ok'
  513.  
  514.     return ret
  515.  
  516.  
  517. def getLocation(bssid, ss):
  518.     log.debug('Getting location for wifi AP: %s' % bssid)
  519.     request = "<?xml version='1.0'?>\n<LocationRQ xmlns='http://skyhookwireless.com/wps/2005' version='2.6' street-address-lookup='full'>\n<authentication version='2.0'>\n<simple>\n<username>beta</username>\n<realm>js.loki.com</realm>\n</simple>\n</authentication>\n<access-point>\n<mac>%s</mac>\n<signal-strength>%d</signal-strength>\n</access-point>\n</LocationRQ>" % (bssid.encode('utf-8'), ss)
  520.     import httplib as httplib
  521.     import socket as socket
  522.     ret = { }
  523.     request_len = len(request)
  524.     log.log_data(request)
  525.     
  526.     try:
  527.         conn = httplib.HTTPSConnection('api.skyhookwireless.com')
  528.         conn.putrequest('POST', '/wps2/location')
  529.         conn.putheader('Content-type', 'text/xml')
  530.         conn.putheader('Content-Length', str(request_len))
  531.         conn.endheaders()
  532.         conn.send(request)
  533.     except (socket.gaierror, socket.error):
  534.         log.debug('Host connection error')
  535.         return { }
  536.  
  537.     response = conn.getresponse()
  538.     if response.status != 200:
  539.         log.debug('Connection to location server failed')
  540.         return { }
  541.     xml = response.read()
  542.     log.log_data(xml)
  543.     
  544.     try:
  545.         params = utils.XMLToDictParser().parseXML(xml)
  546.     except xml.parsers.expat.ExpatError:
  547.         response.status != 200
  548.         response.status != 200
  549.         return { }
  550.  
  551.     if 'locationrs-error' in params:
  552.         log.debug('Location server returned failure')
  553.         return { }
  554.     ret['latitude'] = params.get('locationrs-location-latitude', 0)
  555.     ret['longitude'] = params.get('locationrs-location-longitude', 0)
  556.     street_number = params.get('locationrs-location-street-address-street-number', '')
  557.     street_name = params.get('locationrs-location-street-address-address-line', '')
  558.     city = params.get('locationrs-location-street-address-city', '')
  559.     country = params.get('locationrs-location-street-address-country-code', '')
  560.     address = '%s %s, %s, %s' % (street_number, street_name, city, country)
  561.     ret['address'] = address.strip()
  562.     return ret
  563.  
  564.